package models

import (
	"time"
)

// OrderContract 订单合同表
type OrderContract struct {
	ID                uint64     `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
	ContractNo        string     `gorm:"type:varchar(32);uniqueIndex;not null;comment:合同编号" json:"contract_no"`
	OrderID           uint64     `gorm:"not null;index;comment:订单ID" json:"order_id"`
	ContractType      int8       `gorm:"type:tinyint;not null;index;comment:合同类型(1-租房合同,2-续租合同,3-退租合同,4-转租合同)" json:"contract_type"`
	ContractStatus    int8       `gorm:"type:tinyint;default:0;index;comment:合同状态(0-草稿,1-待签署,2-已签署,3-已作废,4-已过期)" json:"contract_status"`
	ContractURL       string     `gorm:"type:varchar(500);comment:合同URL" json:"contract_url"`
	ContractContent   string     `gorm:"type:text;comment:合同内容" json:"contract_content"`
	TenantSignature   string     `gorm:"type:varchar(500);comment:租客签名" json:"tenant_signature"`
	LandlordSignature string     `gorm:"type:varchar(500);comment:房东签名" json:"landlord_signature"`
	TenantSignedAt    *time.Time `gorm:"type:timestamp;comment:租客签名时间" json:"tenant_signed_at"`
	LandlordSignedAt  *time.Time `gorm:"type:timestamp;comment:房东签名时间" json:"landlord_signed_at"`
	ContractStartDate *time.Time `gorm:"type:date;comment:合同开始日期" json:"contract_start_date"`
	ContractEndDate   *time.Time `gorm:"type:date;comment:合同结束日期" json:"contract_end_date"`
	AutoRenewal       int8       `gorm:"type:tinyint;default:0;comment:是否自动续租(0-否,1-是)" json:"auto_renewal"`
	RenewalNoticeDays int        `gorm:"type:int;default:30;comment:续租提醒天数" json:"renewal_notice_days"`
	CreatedAt         time.Time  `gorm:"autoCreateTime;comment:创建时间" json:"created_at"`
	UpdatedAt         time.Time  `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at"`
}
